package com.guxingke.typecho4j.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertiesUtil {
	private static Properties properties;
	private static String path;

	public static void init(String filePath) throws IOException {
		properties = new Properties();
		File file = new File(filePath);
		path = filePath;
		InputStream is = new FileInputStream(file);
		properties.load(is);
	}

	public static String getValue(String key) {
		return properties.getProperty(key);
	}

	public static void setValue(String key, String value)
			throws FileNotFoundException, IOException {
		properties.setProperty(key, value);
		properties.store(new FileOutputStream(new File(path)), key
				+ " " + value);
	}
}
